var documentId = getHref().documentId
//_______________________________________________________________________________头部信息
			$.get("../contract/"+documentId,function(data){
				data = JSON.parse(data)
				$(".orderStatus").text(commomFun.documentTypeStr(data.data.status))		
				$(".documentNo").text(data.data.id)
				$(".orderPfNo").text(data.data.platformContractId)
				$(".orderCus").text(data.data.customerName)								
				$(".documentPrice").text(data.data.deposit)
				$(".changePrice").val(data.data.deposit)
				var remark = data.data.remark?data.data.remark:"";
				$(".remark").text(remark)
				$(".quoteCurrency").text(commomFun.currencyMStr(data.data.quoteCurrency));
			})
			
//_______________________________________________________________________________
			
			getAjax()
			function getAjax(){	
				$(".clear").empty()
				var startDate = $('.startDate').val();
				var endDate = $('.endDate').val();	
				var dayOfWeek = function(){                    //星期
					var length = $(".dayOfWeek input[type=checkbox]").length;
					var arr = [];
					for(var i=0;i<length;i++){
						if($(".dayOfWeek input[type=checkbox]")[i].checked){
							arr.push($(".dayOfWeek input[type=checkbox]").eq(i).val());
						}
					}
					return arr;
				}();
			    $.get("../contract/"+documentId+"/order?startDate="+startDate+"&dayOfWeek="+dayOfWeek+"&endDate="+endDate+"&temp="+Math.random(),function(data){
					data = JSON.parse(data)
					$('.totalOrder').text(data.data.length)
					var strOrderMess = "";
					
					for(var i in data.data){
						var singleSignStr = "";
						var data_ = data.data[i];
						if(data_.single=="2"){
							singleSignStr+="<label class='singleProductSign'>单边</label>";
						}
						strOrderMess += "<tr class='orderMessTr'>" +
										  "<td><input class='check' type='checkbox' id="+data_.id+">订单号:<span class='fontf9a000 orderId'>"+data_.id+"</span>"+singleSignStr+"</td>" +										  
										  "<td></td>" +
										  "<td></td>" +
										  "<td></td>" +
										  "<td></td>" +	
										  "<td>数量:<b>"+data_.passengerTotal+"</b></td>" +
										  "<td>出票率:<b>"+data_.ticketRate+"</b></td>" +
										  "<td>票损:<b>"+data_.ticketLoss+"</b></td>" +
										  "<td>票损率:<b>"+data_.ticketLossRate+"</b></td>" +
									   "</tr><tr>"
						
						for(var j=0;j<data_.itineraries.length;j++){	
							var itineraries_ = data_.itineraries[j];
							var tabledayOfWeek = (itineraries_.dayOfWeek=="0")?"7":itineraries_.dayOfWeek;	
							var length=data_.itineraries.length;
							
							strOrderMess+= "<td>"+itineraries_.flightNumber+"</td>"+
							    		   "<td>"+tabledayOfWeek+"</td>"+
							    		   "<td>"+itineraries_.departureAirport+"("+itineraries_.departureAirportCode+")<span style='color:#00aa98;'>"+itineraries_.departureAirportTerminal+"</span></br>"+itineraries_.departureDate+"&nbsp;&nbsp;&nbsp;"+itineraries_.departureTime+"</td>"+
							    		   "<td>"+itineraries_.arriveAirport+"("+itineraries_.arriveAirportCode+")<span style='color:#00aa98;'>"+itineraries_.arriveAirportTerminal+"</span></br>"+itineraries_.arriveAirportDate+"&nbsp;&nbsp;&nbsp;"+itineraries_.arriveAirportTime+"</td>"+					   
										   "<td>"+itineraries_.seatClass+"</td>"
							if(j==0){				 
								strOrderMess+="<td rowspan="+length+"><span class='font00aa98'>"+data_.price+"</span><span class='fontaaaaaa'>/</span>"+commomFun.toLine(data_.viewAdultPrice)+"</td>"+
								   "<td rowspan="+length+"><span class='font00aa98'>"+commomFun.toEmptyString(data_.childPrice)+"</span><span class='fontaaaaaa'>/</span>"+commomFun.toLine(data_.viewChildPrice)+"</td>"+
								   "<td rowspan="+length+"><span class='font00aa98'>"+commomFun.toEmptyString(data_.infantPrice)+"</span><span class='fontaaaaaa'>/</span>"+commomFun.toLine(data_.viewInfantPrice)+"</td>"+		
								   "<td rowspan="+length+"><span class='edit iconfont'" +
								   								" id="+data_.id+
								   								" passengerTotal="+data_.passengerTotal+
								   								" ticketLoss="+data_.ticketLoss+
								   								" ticketLossRate="+data_.ticketLossRate+
								   								" ticketRate="+data_.ticketRate+
								   								" price="+data_.price+
								   								" viewAdultPrice="+data_.viewAdultPrice+
								   								" childPrice="+data_.childPrice+
								   								" viewChildPrice="+data_.viewChildPrice+	
								   								" infantPrice="+data_.infantPrice+
								   								" viewInfantPrice="+data_.viewInfantPrice+								   								
								   		">&#xe681;</span></td>"
				          		 
							}else{
								strOrderMess+="";
							}				   
							    strOrderMess+="</tr>";			  
						}
					}
					$(".clear").append(strOrderMess)
				})
			}


//_______________________________________________________________________________点击查询
			$(".query").click(function(){
				getAjax()
			})
//_______________________________________________________________________________点击订单号号至订单详情
	$('.clear').delegate(".orderId","click",function(){	
		var id=$(this).text();//获取当前订单状态的id值	
		layer.open({
			type: 2,
			title: false,
			closeBtn: 0,
			shadeClose: true,
			shade: 0.3,
			area: ['100%', '100%'],  
			content: ['../ak/embedDiv.html?id='+id],// iframe的url，no代表不显示滚动条
			end:function(){
				
			}
				
		});
	 })		
//_______________________________________________________________________________批量修改
			$(".change").click(function(){
				var checkedOrder = $(".clear .check:checked");
				if(checkedOrder.length==0){
					layer.msg("请选择订单",{icon:2})
					return false;
				}
				var idArr = [];
				$.each(checkedOrder, function(index, item){     
					idArr.push($(item).attr("id"));    
				});
				layer.open({
			        type: 2,
			        title: ['审核信息','background-color:#6d6e72; color:#fff;'],
			        shadeClose: true,
			        shade: [0.9,'#cfcfcf'],
			        area: ['430px', '85%'],  
			        content: ['../ak/auditMess.html?idArr='+idArr],// iframe的url，no代表不显示滚动条
			        end:function(){
			        	getAjax();
			        }			          
			     });	
			})
//_______________________________________________________________________________单个修改
											
			$(".clear").delegate(".edit","click",function(){
				changeOneOrderData = {
						"id":$(this).attr("id"),
						"passengerTotal":$(this).attr("passengerTotal"),
						"ticketLoss":$(this).attr("ticketLoss"),
						"ticketLossRate":$(this).attr("ticketLossRate"),
						"ticketRate":$(this).attr("ticketRate"),
						"price":$(this).attr("price"),
						"viewAdultPrice":$(this).attr("viewAdultPrice"),
						"childPrice":$(this).attr("childPrice"),
						"viewChildPrice":$(this).attr("viewChildPrice"),
						"infantPrice":$(this).attr("infantPrice"),
						"viewInfantPrice":$(this).attr("viewInfantPrice")
				}				
				layer.open({
			        type: 2,
			        title: ['审核信息','background-color:#6d6e72; color:#fff;'],
			        shadeClose: true,
			        shade: [0.9,'#cfcfcf'],
			        area: ['430px', '85%'],  
			        content: ['../ak/auditMess.html'],// iframe的url，no代表不显示滚动条
			        end:function(){
			        	getAjax();
			        }			          
			     });	
			})
//_______________________________________________________________________________________合同审核
			$(".sure").click(function(){
				var reason = $('.reason').val()
				var status = $("input:radio[name='choose']:checked").val();
				var deposit = $(".changePrice").val();				
				var depositPaymentDeadline = $(".depositPaymentDeadline").val();
				var orderPaymentDeadline = $(".orderPaymentDeadline").val();
				var commitPassengerDeadline = $(".commitPassengerDeadline").val();	
				var advanceConfirmDays = $(".advanceConfirmDays").val();
				var checkedAndunChecked = function(){										
											var checked = [];
											var unChecked = [];
											var length = $('.clear input:checkbox').length
											for(var i=0;i<length;i++){
												if($('.clear input:checkbox')[i].checked){
													checked.push($('.clear input:checkbox').eq(i).attr("id"))
												}else{
													unChecked.push($('.clear input:checkbox').eq(i).attr("id"))
												}
											}												
											return {"checked":checked,"unChecked":unChecked};																				
										}();
				var checked = checkedAndunChecked.checked;
				var unChecked = checkedAndunChecked.unChecked;
	
				if(status=="2"){
					if(deposit==""){
						layer.msg("押金不能为空",{icon: 2,time:2000})
						return false;
					}else if(!/^\d+(\.\d+)?$/.test(deposit)){
						layer.msg("押金为数字",{icon: 2,time:2000})
						return false;
					}else if(/^\d+(\.\d+)$/.test(deposit)&&(deposit.split(".")[1].length>2)){
						layer.msg("押金的小数精度不超过两位",{icon: 2,time:1000})
						return false; 
					}
					
					if(depositPaymentDeadline==""){
						layer.msg("支付时限不能为空",{icon: 2,time:2000})
						return false;
					}else if(!/^\d+$/.test(depositPaymentDeadline)){
						layer.msg("支付时限为整数",{icon: 2,time:2000})
						return false;
					}
					
					if(orderPaymentDeadline==""){
						layer.msg("支付时限不能为空",{icon: 2,time:2000})
						return false;
					}else if(!/^\d+$/.test(orderPaymentDeadline)){
						layer.msg("支付时限为整数",{icon: 2,time:2000})
						return false;
					}
					
					if(commitPassengerDeadline==""){
						layer.msg("支付时限不能为空",{icon: 2,time:2000})
						return false;
					}else if(!/^\d+$/.test(commitPassengerDeadline)){
						layer.msg("支付时限为整数",{icon: 2,time:2000})
						return false;
					}
					
					if(advanceConfirmDays==""){
						layer.msg("提前确认天数不能为空",{icon: 2,time:2000})
						return false;
					}else if(!/^\d+$/.test(advanceConfirmDays)){
						layer.msg("提前确认天数为整数",{icon: 2,time:2000})
						return false;
					}
					if(checked.length==0){
						layer.msg("请选择所要审核的订单",{icon: 2,time:2000})
						return false;
					}
				}
				layer.msg('审核中...', {icon: 16,shade: 0.01});
				var str={
						 "status":status,
						 "auditOpinion":reason,
						 "deposit":deposit,
						 "depositPaymentDeadline":depositPaymentDeadline,
						 "orderPaymentDeadline":orderPaymentDeadline,
						 "commitPassengerDeadline":commitPassengerDeadline,
						 "advanceConfirmDays":advanceConfirmDays,
						 "checked":checked,
						 "unChecked":unChecked
					};
				if(reason==''||status==''){
					layer.msg('请填写详细信息', {icon: 2,time:2000},function(){
						
					})	
					return false;
				}else{
					$.ajax({
						type:"post",
						contentType:'application/json;charset=utf-8',
						url:"../contract/"+documentId+"/audit?temp="+Math.random(),
						async:true,
						data:JSON.stringify(str),
						success:function(data){
							data = JSON.parse(data)
							if(data.status=='1001'){
								layer.msg('审核完成', {icon: 1,time:1000},function(){
									var index = parent.layer.getFrameIndex(window.name);//获取弹窗索引
									parent.layer.close(index);//关闭弹窗
								})						
							}else{
								//审核失败的弹出框
								layer.confirm("审核失败"+data.message, {
									title:['审核失败','background-color:#6d6e72; color:#fff;'],
								   	btn: ['确定'] //按钮
								}, function(){
									layer.closeAll('dialog');
								});								
							}								
						}
					})				
				}		
			})
			